package com.zjm.servlet.servlet03_three_ways;

import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author ZJM
 * @date 2024/4/11 22:14
 * 方式2：继承javax.servlet.GenericServlet抽象类
 * <p>
 * 重写父类中的方法，通常会重写service()方法来处理请求。
 */
public class Way02Servlet extends GenericServlet {

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        servletResponse.setContentType("text/html;charset=UTF-8");
        PrintWriter out = servletResponse.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + "方式2：继承javax.servlet.GenericServlet抽象类" + "</h1>");
        out.println("</body></html>");
    }
}
